package com.boang.entity;

import java.util.Objects;
import java.util.Scanner;

/*
    @author:sa
    @date:2024/11/19 9:25
*/
public class ATM {
    public Bank bank;
    public Scanner scanner;
    public Account account;

    public ATM() {
        scanner = new Scanner(System.in);
        bank = new Bank();
//        Account[]accounts=new Account[2];
    }
//    public int saveMoney(){
//        return account.balance;
//    }

    public void service() {
        System.out.println("请输入卡号");
        String carNo = scanner.nextLine();
        System.out.println("请输入密码");
        String pass = scanner.nextLine();
        Account account = bank.verify(carNo, pass);
        if (!Objects.isNull(account)) {
            do {
                System.out.println("1.存钱，2.取钱3.查看");
                String cq = scanner.nextLine();
                switch (cq) {
                    case "1":
                        System.out.println("请把人民币放入机器中");
                        int money = scanner.nextInt();
                        bank.saveMoney(money, account);
                        break;
                    case "2":
                        System.out.println("请输入要取钱的钱数");
                        int m = scanner.nextInt();
                        bank.depositMoney(m,account);
                        break;
                    case "3":
                        System.out.println(account.balance);
                        break;
                }
            }
            while (true);
        }
    }
}